<template>
    <component :is="url ? 'router-link' : 'div'" class="yy-hotel-item" :class="['yy-hotel-item--' + type]" :to="url">
        <span class="yy-hotel-item__total">{{peopleTotal || '0'}}</span>
        <el-tooltip
            class="item"
            effect="dark"
            :content="name"
            placement="top"
        >
            <strong class="yy-hotel-item__title">{{name || '--'}}</strong>
        </el-tooltip>
    </component>
</template>
<script>
export default {
    name: 'YyHotelItem',
    props: {
        url: {
            type: String
        },
        type: {
            type: String,
            default: 'once',
            validator (value) {
                return ['once', 'double', 'triple'].indexOf(value) >= 0
            }
        },
        name: {
            type: String
        },
        peopleTotal: {
            type: Number
        }
    }
}
</script>
<style>
.yy-hotel-item{
    border-width: 1px;
    border-style: solid;
    border-radius: 3px;
    text-align: center;
    padding: 18px 6px;
    position: relative;
    cursor: pointer;
    display: block;
}
.yy-hotel-item:after{
    content: '';
    position: absolute;
    top: -5px;
    right: -5px;
    border: 12px solid #000;
    border-left-color: transparent!important;
    border-bottom-color: transparent!important;
    font-size: 0;
    width: 0;
    height: 0;
    line-height: 0;
    overflow: hidden;
    transform: scale(.5);
    border-radius: 5px;
}
.yy-hotel-item__title{
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 24px;
    line-height: 24px;
    margin-top: 12px;
    font-size: 16px;
}
.yy-hotel-item__total{
    font-size: 24px;
    font-weight: bold;
    display: block;
    height: 24px;
    line-height: 24px;
}
.yy-hotel-item--once{
    border-color: #61c39d;
    color: #61c39d;
    background-color: rgba(97, 195, 157, 0.1);
}
.yy-hotel-item--once:after{
    border-color: #61c39d;
}
.yy-hotel-item--double{
    border-color: #4d9cfd;
    color: #4d9cfd;
    background-color: rgba(77, 156, 253, 0.1);
}
.yy-hotel-item--double:after{
    border-color: #4d9cfd;
}
.yy-hotel-item--triple{
    border-color: #7662d5;
    color: #7662d5;
    background-color: rgba(118, 98, 213, 0.1);
}
.yy-hotel-item--triple:after{
    border-color: #7662d5;
}
</style>